package com.woniuxy.pxxt.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <P> @Author: ideaAdmin
 * <P> TODO: Class
 * <P> TODO: 记录用户的培训状态
 * <P> Date: 2022/3/7:20:15
 * <P> Description:
 */

public enum UserTrainStatus {

    TRAIN_NO_AUTH(1, "认证中"),
    TRAIN_NO_COMPLETE(2, "培训未完成"),
    TRAIN_SUCCESS(3, "培训完成"),
    TRAIN_TEST_FAIL(4, "考试失败"),
    TRAIN_TEST_SUCCESS(5, "通过考试"),
    ;

    private Integer status;
    private String name;

    UserTrainStatus(Integer status, String name) {
        this.status = status;
        this.name = name;
    }

    public static String getStatusNameByStatus(Integer status) {
        UserTrainStatus arrObj[] = UserTrainStatus.values();
        for (UserTrainStatus obj : arrObj) {
            if (status.intValue() == obj.getStatus().intValue()) {
                return obj.getName();
            }
        }
        return "";
    }

    public static Integer getStatusInteger(String  name) {
        UserTrainStatus arrObj[] = UserTrainStatus.values();
        for (UserTrainStatus obj : arrObj) {
            if (name.equals(obj.name) ) {
                return obj.getStatus();
            }
        }
        return -1;
    }


    public static List<Map<String,Object>> getStatusList() {
        List<Map<String,Object>> list = new ArrayList<>();

        UserTrainStatus arrObj[] = UserTrainStatus.values();

        for (UserTrainStatus obj : arrObj) {
            Map<String,Object> map = new HashMap<>();
            map.put("status", obj.getStatus());
            map.put("comment", obj.getName());
            list.add(map);
        }
        return list;
    }


    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
